

<template>
  <div>

		<van-nav-bar
	  title="填写地址"
	  style="background: #fff;"
	  left-arrow
	  @click-left="onClickLeft"
	  />
		<div class="van_address_edit_content">

	  	<van-address-edit
			  :area-list="areaList"
			  :search-result="searchResult"
			  @save="onSave"
			  @change-detail="onChangeDetail"
			/>
	  </div>
    <div class=""vanoverlay>
      <van-overlay :show="show" @click="show = false">
         <van-loading type="spinner" color="#fff" />
      </van-overlay>
    </div>


  </div>

<!--    <van-popup v-model="show" position="bottom">-->
<!--      -->
<!--    </van-popup>-->




</template>
<script>

import Area from '@/json/area.js';

export default {
  data(){
      return {
          areaList:Area,
          searchResult: [],
          user:'',
          show:false,
          three_list:[]
      }
    },
    mounted:function(){
        const that = this;
        let local_user = localStorage.getItem("user");
        if (local_user != undefined && local_user != "undefined") {
            let user = JSON.parse(local_user);
            that.user = user;
        }
        that.three_list=that.$route.query.res;
        console.log(that.three_list);
    },
  methods: {
  	 onSave(event) {
         const  that = this;
         let params = "userId="+that.user.userId+"&name="+event.name+"&mobile="+event.tel+"&address_detail="+event.addressDetail+"&province="
         +event.province+"&city="+event.city+"&county="+event.county;
          that.show= true;
         this.$sendRequest('/recycle/add_address_h5',params).then(function(res){
             that.show= false;
             if(res.data.code ==0){
                 that.$router.push({
                     path: "/Immediate",query:{three_list:that.three_list}
                 });
             }else if(res.data.code ==2){
                 that.$toast(res.data.msg);
             }
         })
  	     /*console.log(this.areaList);
  	     console.log(event);
         console.log(event.tel);
         console.log(event.province);
         console.log(event.city);
         console.log(event.county);
         console.log(event.addressDetail);
         console.log(event.name);*/

    },
    onDelete() {

    },

    onChangeDetail(val) {

    },
  	onClickLeft(){
        this.$router.push({
            path: "/Immediate",query:{three_list:this.three_list}
        });
  	}
  }
}

</script>

<style scoped="scoped">
	.van_address_edit_content >>> .van-button--danger{
		background: #4C9FFDFF;
		border:1px solid #4C9FFDFF;
		border-radius: 5vh;
	}
	.amap-wrapper {
	  width: 500px;
	  height: 500px;
	}
  .van-overlay >>>.van-loading{
    position: absolute;
    left: 49%;
    top: 29%
  }
</style>



